home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / asppw112 / freadwri.asp < prev    next >
Text File  |  1999-01-07  |  2KB  |  64 lines

  1. <HTML><BODY>
  2. <%
  3.     ' ReadFile(ByVal vsPathName As String) As String
  4.     ' output:   file contents as string
  5.     '          ""   Failure
  6.               
  7.     ' WriteFile(ByVal vsPathName As String, ByVal vsFileBuff As String) As Integer
  8.     ' output:  >=0   Bytes written
  9.     '          -1   Failure
  10.     '
  11.     ' 
  12.     ' This file is provided as part of  ASP Power Widgets Samples
  13.     '
  14.     ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
  15.     ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
  16.     ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
  17.     ' OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
  18.     ' PURPOSE.
  19.  
  20.     ' Sample Operation:
  21.     ' Pick up a file in virtual directory of "/", read it and write it to a new file demo.bin
  22.     ' Copyright 1997-1998. All rights reserved.
  23.     ' Dalun Software Inc. ASPPW 1.1
  24.     ' http://www.dalun.com
  25.     ' http://members.tripod.com/ActiveServerPage/
  26.  
  27.     sDirName = Server.MapPath("/")
  28.     response.write "<p><h2>Pick up a file in directory """  & sDirName & """ .</h2></p>"
  29.  
  30.     Set oFDMgt = Server.CreateObject("ASPPW.FDMgt")
  31.     if oFDMgt.ReadDir(sDirName)= -1 then
  32.         response.write "Read Directory Action Failed.<br>"
  33.         response.write oFDMgt.GetLastErrDescription
  34.     else
  35.         Set oFilelist = ofdmgt.Files
  36.  
  37.         if oFilelist.count =0 then
  38.             response.write "Demo cann't proceed since there is no file in " & sDirName & "."        
  39.         else
  40.             set file=oFilelist.Item(1)
  41.                 response.write "<font size=2 face=""Courier New"">" & file.Name & "</font><br>"
  42.     
  43.                   buff = ofdmgt.ReadFile(sDirName & "\" & file.Name )
  44.                 if buff="" and oFDMgt.GetLastErrNum <> 0 then
  45.                     response.write "<br>Error: " & oFDMgt.GetLastErrDescription
  46.                 else
  47.                     response.write "<font color=""#800000""><pre>" & server.htmlencode(buff) & "</pre></font>"
  48.                     j = ofdmgt.writeFile(sDirName & "\" & "demo.bin" , buff)
  49.                     response.write cstr(j) & " bytes written to " & sDirName & "\" & "demo.bin.<br>"
  50.                 end if
  51.             end if
  52.             Set oFilelist =nothing
  53.         end if
  54.  
  55.     Set oFDMgt = nothing    
  56.     
  57. %>
  58. </BODY></HTML>
  59.  
  60.  
  61.  
  62.  
  63.  
  64.